<template>
  <div class="app-container">
    <el-card>
      <el-form inline :model="searchForm" size="mini">
        <el-form-item label="公司名称">
          <el-input v-model="searchForm.name" placeholder="请输入公司名称" clearable></el-input>
        </el-form-item>
        <el-form-item label="查询时间：" prop="beginTime">
          <el-date-picker style="width: 200px" v-model="searchForm.beginTime" align="right" type="date"
            placeholder="选择开始日期" :picker-options="$pickerDateOptions" value-format="yyyy-MM-dd"
            format="yyyy 年 MM 月 dd 日">
          </el-date-picker>
        </el-form-item>
        <el-form-item>-</el-form-item>
        <el-form-item prop="endTime">
          <el-date-picker style="width: 200px" v-model="searchForm.endTime" align="right" type="date"
            placeholder="选择结束日期" :picker-options="$pickerDateOptions" value-format="yyyy-MM-dd"
            format="yyyy 年 MM 月 dd 日">
          </el-date-picker>
        </el-form-item>
        <el-form-item>
          <el-button icon="el-icon-refresh" @click="resetForm('searchForm')">重置</el-button>
          <el-button icon="el-icon-search" type="primary" @click="handleSearchList()">查询</el-button>
        </el-form-item>
      </el-form>
      <el-table v-loading="listLoading" :data="tableData.data" border size="mini">
        <el-table-column align="center" label="序号" type="index" width="80"></el-table-column>
        <el-table-column align="center" label="公司名称" prop="enterpriseName"></el-table-column>
        <el-table-column align="center" label="查询人数" prop="searchInquiriesNumber">
          <template slot-scope="scope">
            <el-button @click="reTable(scope.row)" type="text">{{ scope.row.searchInquiriesNumber }}</el-button>
          </template>
        </el-table-column>
        <el-table-column align="center" label="查询次数">
          <template slot-scope="scope">
            <el-button @click="searchTable(scope.row)" type="text">{{ scope.row.searchQueriesNumber }}</el-button>
          </template>
        </el-table-column>
        <el-table-column align="center" label="近三年是否有纳税数据">
          <template slot-scope="scope">
            {{ scope.row.searchInvoice ? '有' : '无' }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="近三年是否有开票数据">
          <template slot-scope="scope">
            {{ scope.row.searchPaidTaxes ? '有' : '无' }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="最晚查询时间" prop="latestSearchData"></el-table-column>
      </el-table>
      <el-pagination class="pageRight" background layout="total, sizes, prev, pager, next, jumper"
        :page-sizes="[10, 20, 50, 100]" :page-size="searchForm.pageSize" :total="tableData.total"
        @size-change="handleSizeChange" @current-change="handleCurrentChange"></el-pagination>
    </el-card>
    <reDetail ref="redetailRef"></reDetail>
    <searchDetail ref="searchDetailRef"></searchDetail>
  </div>
</template>

<script>
import { getBrokerageCompanyList } from '@/api/brokerage'
import reDetail from './components/reDetail.vue'
import searchDetail from './components/searchDetail.vue'
export default {
  components: {
    reDetail,
    searchDetail
  },
  data() {
    return {
      searchForm: {
        pageNum: 1,
        pageSize: 10,
        name: '',
        beginTime: '',
        endTime: '',

      },
      listLoading: false,
      tableData: {
        data: [],
        total: 0
      }
    }
  },
  created() {
    this.getList()
  },
  methods: {
    reTable(v) {
      this.$refs.redetailRef.open(v)
    },
    searchTable(v) { 
      this.$refs.searchDetailRef.open(v)
    },
    resetForm() {
      this.searchForm = {
        pageNum: 1,
        pageSize: 10,
        companyName: '',
        beginTime: '',
        endTime: '',
      }
      this.getList()
    },
    handleSearchList() {
      this.searchForm.pageNum = 1
      this.getList()
    },
    getList() {
      this.listLoading = true
      getBrokerageCompanyList(this.searchForm).then(res => {
        this.tableData.data = res.data.list
        this.tableData.total = res.data.total
      }).finally(() => {
        this.listLoading = false
      })
    },
    handleSizeChange(val) {
      this.searchForm.pageSize = val
      this.getList()
    },
    handleCurrentChange(val) {
      this.searchForm.pageNum = val
      this.getList()
    },

  }
}
</script>

<style></style>